<?php

namespace App\Admin\Structure;

if (!defined('IN_PX'))
    exit;

use App\Admin\AbstractCommon;

/**
 * 内容页
 */
class Content extends AbstractCommon {

    private function __Controller() {}

    protected function __Inject($db) {}

    public function newsContent() {
        if ($this->_boolCanReadData()) {
            $this->rs = $this->db->select('a.*, ars.*')
                ->table('`#@__@archives` a, `#@__@archives_substance` ars')
                ->where('a.`archives_id` = ? AND a.`archives_id` = ars.`archives_id`')
                ->bind(array($_GET['id']))
                ->find();
        }
        if (!isset($_GET['parentId'])){
            $_GET['parentId'] = '';
        }
        if (!isset($_GET['id'])) {
            $_GET['id'] = '';
        }
        $this->sltIDTree = $this->_selectIDTree(array('table' => '`#@__@category`',
            'where' => '`is_display` = 1 AND `channel_type` = 5'),
            array('value' => 'category_id', 'text' => 'category_name',
                'selected' => $this->rs ? $this->rs->category_id : $_GET['parentId']),
            array('disabled' => $this->pageControl));
        $this->getSort = $this->_getSort('archives');

        $this->banners= $this->db->select('`src`')
            ->table('`#@__@archives_attach`')
            ->where('`archives_id` = ?')
            ->bind(array($_GET['id']))
            ->findAll();
        $this->banners = json_encode($this->banners);

        return true;
    }

    public function honorContent() {
        if ($this->_boolCanReadData()) {
            $this->rs = $this->db->select('c.*')
                ->table('`#@__@certificate` c')
                ->where('c.`certificate_id` = ?')
                ->bind(array($_GET['id']))
                ->find();
        }
        return true;
    }

    public function storeContent() {
        if ($this->_boolCanReadData()) {
            $this->rs = $this->db->select('c.*')
                ->table('`#@__@certificate` c')
                ->where('c.`certificate_id` = ?')
                ->bind(array($_GET['id']))
                ->find();
        }
        return true;
    }

    public function productContent() {
        if ($this->_boolCanReadData()) {
            $this->rs = $this->db->select('c.*')
                ->table('`#@__@certificate` c')
                ->where('c.`certificate_id` = ?')
                ->bind(array($_GET['id']))
                ->find();
        }
        return true;
    }

    public function questionContent() {
        if ($this->_boolCanReadData()) {
            $this->rs = $this->db->select('c.*')
                ->table('`#@__@certificate` c')
                ->where('c.`certificate_id` = ?')
                ->bind(array($_GET['id']))
                ->find();
        }
        return true;
    }

    public function typeContent() {
        if ($this->_boolCanReadData()) {
            $this->rs = $this->db->select('c.*')
                ->table('`#@__@map` c')
                ->where('c.`map_id` = ?')
                ->bind(array($_GET['id']))
                ->find();
        }

        return true;
    }

    public function territoryContent() {
        if ($this->_boolCanReadData()) {
            $this->rs = $this->db->select('c.*')
                ->table('`#@__@certificate` c')
                ->where('c.`certificate_id` = ?')
                ->bind(array($_GET['id']))
                ->find();
        }

        $this->sltIDTree = $this->_selectIDTree(array('table' => '`#@__@map`',
            'where' => '', 'select' => '*', 'order' => '', 'sort' => ''),
            array('value' => 'map_id', 'text' => 'map_title',
                'selected' => $this->rs ? $this->rs->is_status : $_GET['parentId']),
            array('disabled' => $this->pageControl));

        return true;
    }

    public function recruitContent() {
        if ($this->_boolCanReadData()) {
            $this->rs = $this->db->select('a.*')
                ->table('`#@__@recruit` a')
                ->where('a.`archives_id` = ?')
                ->bind(array($_GET['id']))
                ->find();
        }
        if (!isset($_GET['parentId'])){
            $_GET['parentId'] = '';
        }
        if (!isset($_GET['id'])) {
            $_GET['id'] = '';
        }
        $this->getSort = $this->_getSort('recruit');
        return true;
    }

    public function brandContent() {
        if ($this->_boolCanReadData()) {
            $this->rs = $this->db->select('c.*')
                ->table('`#@__@certificate` c')
                ->where('c.`certificate_id` = ?')
                ->bind(array($_GET['id']))
                ->find();
        }
        return true;
    }

    public function enterpriseContent() {
        if ($this->_boolCanReadData()) {
            $this->rs = $this->db->select('c.*')
                ->table('`#@__@certificate` c')
                ->where('c.`certificate_id` = ?')
                ->bind(array($_GET['id']))
                ->find();
        }
        return true;
    }

    public function largeContent() {
        if ($this->_boolCanReadData()) {
            $this->rs = $this->db->select('c.*')
                ->table('`#@__@certificate` c')
                ->where('c.`certificate_id` = ?')
                ->bind(array($_GET['id']))
                ->find();
        }
        return true;
    }

    public function videoContent() {
        if ($this->_boolCanReadData()) {
            $this->rs = $this->db->select('c.*')
                ->table('`#@__@certificate` c')
                ->where('c.`certificate_id` = ?')
                ->bind(array($_GET['id']))
                ->find();
        }
        return true;
    }

    public function managementContent() {
        if ($this->_boolCanReadData()) {
            $this->rs = $this->db->select('c.*')
                ->table('`#@__@certificate` c')
                ->where('c.`certificate_id` = ?')
                ->bind(array($_GET['id']))
                ->find();
        }
        return true;
    }

    public function joinContent() {
        if ($this->_boolCanReadData()) {
            $this->rs = $this->db->select('c.*')
                ->table('`#@__@certificate` c')
                ->where('c.`certificate_id` = ?')
                ->bind(array($_GET['id']))
                ->find();
        }
        return true;
    }


    public function categoryContent() {
        if ($this->_boolCanReadData()) {
            $this->rs = $this->db->select('c.*, cs.*')
                ->table('`#@__@category` c, `#@__@category_substance` cs')
                ->where('c.`category_id` = ? AND c.`category_id` = cs.`category_id`')
                ->bind(array($_GET['id']))
                ->find();
        }
        if (!isset($_GET['parentId'])) {
            $_GET['parentId'] = '';
        }
        if (!isset($_GET['parentChannelType'])) {
            $_GET['parentChannelType'] = 0;
        }
        if (!isset($_GET['parentIsPart'])) {
            $_GET['parentIsPart'] = 0;
        }
        if (!isset($_GET['parentNavType'])) {
            $_GET['parentNavType'] = 0;
        }
        if (!isset($_GET['id'])) {
            $_GET['id'] = '';
        }
        $this->sltIDTree = $this->_selectIDTree(array('table' => '`#@__@category`',
            'where' => '`is_display` = 1'),
            array('value' => 'category_id', 'text' => 'category_name',
                'selected' => $this->rs ? $this->rs->parent_id : $_GET['parentId']),
            array('disabled' => $this->pageControl));
        $this->getSort = $this->_getSort();
        return true;
    }


    public function adContent() {
        if ($this->_boolCanReadData()) {
            $this->rs = $this->db->select()
                ->table('`#@__@ad`')
                ->where('`ad_id` = ?')
                ->bind(array($_GET['id']))
                ->find();
        }
        if (!isset($_GET['parentId'])) {
            $_GET['parentId'] = '';
        }
        if (!isset($_GET['id'])) {
            $_GET['id'] = '';
        }
        $this->getSort = $this->_getSort('ad', 'ad_sort');
        return true;
    }

    public function synopsisContent() {
        if ($this->_boolCanReadData()) {
            $this->rs = $this->db->select()
                ->table('`#@__@synopsis`')
                ->where('`ad_id` = ?')
                ->bind(array($_GET['id']))
                ->find();
        }
        $this->getSort = $this->_getSort('synopsis', 'ad_sort');
        return true;
    }

}
